The present invention relates generally to the development of fixed-point algorithms and more particularly to a methodology employing C++ class definitions for converting floating-point algorithms to corresponding target-specific fixed-point algorithms to be used, for example, in signal processing applications.
In the early development stage of many high-complexity algorithms such as, for example, signal processing algorithms, software developers commonly perform the initial implementations using xe2x80x9cfloating-pointxe2x80x9d variables and arithmetic. This is done in order to bypass the burden of dealing with complex practical implementation issues, such as computation overflow, and therefore to speed up the algorithm development process. Once (or even before) this high level task is finalized, however, it is usually necessary to convert the implemented algorithms to a lower level xe2x80x9cfixed-pointxe2x80x9d description. Such a need is driven, inter alia, by the fact that the algorithms must ultimately be implemented in more cost-efficient fixed-point processors, and/or they involve communications-related applications for which bit compliance may be critical in order to retain portability across different platforms.
Most typically, a three-stage procedure for fixed-point prototyping of floating-point algorithms is employed. The first stage is used to collect statistical information about the implemented floating-point algorithm (i.e., the initially implemented code), such as, for example, the dynamic range of the floating-point variables which are used in the code. The second stage is used to transform these floating-point variables into corresponding fixed-point representations. And the third stage replaces all floating-point operations with appropriately defined fixed-point operations, thereby allowing the code to operate on a fixed-point processor. In particular, this third stage may advantageously assume a particular target fixed-point processor, thereby allowing for the fixed-point operations to be defined so as to emulate those of the target processor.
Unfortunately, traditional approaches to the conversion of the initial floating-point algorithm code to a fixed-point implementation, even when using the above-described three stage procedure, invariably have several serious drawbacks. In particular, they tend to be inefficient, inflexible, tedious, and error prone. The original source code must be modified in a manner such that the final code appearance and the logical flow thereof are often quite different from that of the original (i.e., floating-point) code. Moreover, a substantial investment in time is usually required to perform the conversion, resulting in both high manpower costs as well as substantial real-time delays.
To circumvent the drawbacks of traditional approaches to the development of fixed-point algorithms initially implemented as floating-point code, a new methodology is proposed in accordance with the principles of the present invention. In particular, and in accordance with an illustrative embodiment of the method of the present invention, most of the tedious operations which need to be performed across the various stages of such a conversion procedure may be advantageously hidden inside the definitions of a set of C++ classes. With the aid of these C++ class definitions, the fixed-point design process can be substantially simplified. In accordance with the principles of the present invention as embodied in a preferred embodiment thereof, a programmer need only to include and/or exclude certain previously defined header files, and to change the variable declarations within the floating-point code, in order to simulate the source code across various stages of the above-described conversion process.
Specifically, in accordance with an illustrative embodiment of the present invention, a three-step method is provided for transforming a first set of program code including floating-point operations into a second set of program code in which fixed-point operations have been substituted for the floating-point operations. First, the illustrative method modifies the first set of program code by substituting for the floating-point variables of interest one or more newly defined data types which have been defined together with associated overloaded assignment operators for capturing the dynamic ranges of the floating-point variables upon the execution of modified code. Then, this modified program code is compiled and executed, thereby capturing the relevant dynamic range information. Finally, the code is modified again, this time by specifying additional data types defining one or more integer representation formats, and substituting for the (previously) floating-point variables the appropriate one of these data types based on the determined dynamic range therefor. In addition, one or more member functions are associated with each of these additional data types for converting between the given integer representation format and floating-point values.